package com.prelearning.at_springboot.mapper;

import com.prelearning.at_springboot.entity.Published;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author cgr
 * @since 2022-04-10
 */
public interface PublishedMapper extends BaseMapper<Published> {

    //根据用户id获取正在进行的签到
    @Select("SELECT * FROM published WHERE result LIKE CONCAT('%',#{user_id},'%') AND publish_status= 1")
    List<Published> getByUserId(String user_id);

    //获取所有正在进行的签到
    @Select("SELECT * FROM published WHERE  publish_status= 1")
    List<Published> getPublishing();

    //根据用户id获取已发布的签到，按发布时间倒序
    @Select("SELECT * FROM published WHERE result LIKE CONCAT('%',#{user_id},'%') ORDER BY creat_time DESC")
    List<Published> getFinished(String user_id);

    //根据群主id获取已发布签到,按发布的时间倒序
    @Select("SELECT * FROM published WHERE user_id=#{owner_id} ORDER BY creat_time DESC")
    List<Published> getPublished(String owner_id);
}
